<?php
declare (strict_types = 1);

namespace app\api\middleware;

class Log
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //记录当前请求信息
        if(input('get.no_encrypt') == 1){
            $data = file_get_contents("php://input");
        }else{
            $request_data = file_get_contents("php://input");
            $data = aes_decrypt($request_data);
        }
        \think\facade\Log::channel('request')->write($data);

        return $next($request);
    }
}
